<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        ! function() {
            var a = 1;

            function fn() {
                // 'use strict'; //报错
                console.log(a); // undefined
                var a = b = c = 9;
                console.log(a, b, c); // 9,9,9
            }
            fn();
            console.log(a, b, c); //1,9,9
        }();
        console.log('------------------');
        ~ function() {
            function fn() {
                a = 10;
                console.log(a);
            }
            // console.log(a); // 报错
            fn();
            console.log(a);
            var b = new Array('110'); // 构造函数只有一个值(并且为数字型,否则也是单个元素值)的话这个数值就是数组的长度，多个值的话就是数组的值
            console.log(b);
            var timer = setInterval(function() {
                alert(111);
            }, 1000);
            clearInterval(timer); // 定时器函数不会执行
        }();
        console.log('------------------------');
        (function() {
            var b = 100;

            function fn1(x) {
                var a = 100;
                b = 10; // var a = 100,b = 10 等价于var a = 100;var b = 10;这里面的b是全局变量
                console.log(a, b, x) // 100.10,20,1000
                    // console.log(d); // 报错,里面的可以访问外面的内容，外面的不能访问里面的内容
                function fn2(x) {
                    d = 1000;
                    console.log('aaa');
                }
                fn2(x);
            }
            fn1(20);
            console.log(b);
        })();
    </script>
</body>

</html>